<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <script src="jquery.js"></script>
</head>
<body>
<%out.println(1);%>
<%="2"+"4"%>
<table border="1">

    <input type="button" value="添加" onclick="location.href = 'add.jsp'">

    <tr>
        <th>编号</th>
        <th>器材名称</th>
        <th>器材单价</th>
        <th>器材数量</th>
        <th>状态</th>
        <th>采购时间</th>
        <th>操作</th>
    </tr>
    <c:forEach items="${list}" var="fitnessEquipment">
        <tr>
            <td>${fitnessEquipment.id}</td>
            <td>${fitnessEquipment.name}</td>
            <td>${fitnessEquipment.price}</td>
            <td>${fitnessEquipment.count}</td>
            <td>${fitnessEquipment.status == 0?"未投入使用":"已投入使用"}</td>
            <td>${fitnessEquipment.buyTime}</td>
            <td><a href="javascript:del(${fitnessEquipment.id})">删除</a></td>
        </tr>
    </c:forEach>
</table>

<script>
    function del(id) {
        if (confirm("确定要删除吗？")) {
            $.post("delete", {id: id}, res => {
                if (res > 0) {
                    alert("删除成功！")
                    location.reload()
                } else {
                    alert("删除失败！")
                }
            })
        }
    }

</script>
</body>
</html>
